package 剑指offer_力扣版.Month07.day04数组;

public class 左右两边子数组的和相等 {
    public int pivotIndex(int[] nums) {
        int sum = 0,cur = 0;
        for(int i:nums) sum += i;
        for(int i = 0;i < nums.length; i++){
            sum -= nums[i];
            if(sum == cur) return i;
            cur += nums[i];
        }
        return -1;
    }
}
